package main

import (
	"flag"
	//"context"

	"gitee.com/segeln/grit"
	"gitee.com/segeln/grit/conf"
	pb "gitee.com/segeln/grit/example/protoc"
	handler "gitee.com/segeln/grit/example/server/handler"
)

/*
//定义一个helloServer并实现约定的接口
type helloService struct{}

func (h helloService) SayHello(ctx context.Context, in *pb.HelloReq) (*pb.HelloRep, error) {
	resp := new(pb.HelloRep)
	resp.Rep = "reply2342342 : " + in.Req
	return resp, nil
}
func (h helloService) CallHello(ctx context.Context, in *pb.HelloReq) (*pb.HelloRep, error) {
	resp := new(pb.HelloRep)
	resp.Rep = "callll : " + in.Req
	return resp, nil
}

var HelloServer = helloService{}
*/
func main() {
	//port := flag.Int("port", 9001, "service port")
	//sid := flag.   ("sid", 9001, "service id")
	//	sid := flag.String("sid", "sid1", "service id")

	cfg := flag.String("cfg", "server.cfg", "service config file")
	flag.Parse()
	conf.SetConfigFile(*cfg)

	s := grit.NewService(
		conf.Version(Version),
	//conf.Port(*port),
	//conf.ServiceID(*sid),
	)
	//s.Init()
	pb.RegisterHelloServer(s.Server(), handler.HelloServer)
	s.Init()
	s.Run()
}
